#!/usr/bin/env python3
import markdown, sys, os, re, time
if len(sys.argv) <= 1:
	sys.exit("no enough arguments")
infile = open(sys.argv[1])
outfile = open(os.path.splitext(sys.argv[1])[0] + '.html', 'w')
outfile.write("<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n")
if len(sys.argv) >= 2 and re.match(".*.css", sys.argv[2]):
	outfile.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + sys.argv[2] + "\">\n")
outfile.write("</head>\n<body>\n" + markdown.markdown(infile.read(), extensions = ["markdown.extensions.extra"]) + "\n<br /><br />\n<small><small>最后修改于" + time.ctime(os.path.getctime(sys.argv[1])) + "</small></small>\n</body>\n</html>")
